package com.tiancheng.trade.order.task;

import com.tiancheng.trade.order.service.SubOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 每日处理核销异常的订单
 *
 * @author lkl
 * @date 2021/3/17
 */
@Component
@Slf4j
public class VerificationTask {
    /**
     * 每日处理核销异常的订单
     * - 读取清分状态为异常的订单，重新发起核销操作，如果过成功则标记为核销成功，否则标记为核销失败
     *
     * @param param {@link String} 指定的某个时间起
     * @return {@link ReturnT<String>}
     */

    @Autowired
    private SubOrderService subOrderService;
//
//    @XxlJob("verificationErrorHandle")
//    public ReturnT<String> verificationErrorHandle(String param) {
//        List<SubOrder> subOrders = subOrderService.verificationErrorOrder();
//        if(CollectionUtils.isEmpty(subOrders)){
//            log.info("暂无需要重新处理的清分异常订单！");
//            return ReturnT.SUCCESS;
//        }
//        long startTime = System.currentTimeMillis();    //获取开始时间
//        List<String> subOrderIds = subOrders.stream().map(SubOrder::getSubOrderId).collect(Collectors.toList());
//        VerificationOrderVO verificationOrderVO = new VerificationOrderVO();
//        verificationOrderVO.setSubOrderId(subOrderIds);
//        Map<String, Object> verificationResult = subOrderService.verification(verificationOrderVO);
//        long endTime = System.currentTimeMillis();    //获取结束时间
//        log.info("重发核销完成，执行结果：{}", JsonUtil.toJsonString(verificationResult));
//        log.info("重发核销完成，共耗时：{}",Float.toString((endTime - startTime) / 1000F));
//        return ReturnT.SUCCESS;
//    }
}
